package org.asset.until;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class R<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> R<T> success(String msg) {
        return ResultVo(200, msg, null);
    }

    public static <T> R<T> success(String msg, T data) {
        return ResultVo(200, msg, data);
    }

    public static <T> R<T> fail(String msg) {
        return ResultVo(500, msg, null);
    }

    public static <T> R<T> fail(String msg, T data) {
        return ResultVo(500, msg, data);
    }

    public static <T> R<T> ResultVo(int code, String msg, T data){
        R<T> apiResult = new R<>();
        apiResult.setCode(code);
        apiResult.setMsg(msg);
        apiResult.setData(data);
        return apiResult;
    }
}
